/**
 * Created with IntelliJ IDEA
 * Description:
 * User: lv
 * Date: 2023-03-18
 * Time: 15:53
 */

class OuterClass2{
    public int data1=1;
    private int data2=2;
    public static int data3=3;

    //静态内部类
    //1.实例化内部类对象：
    //2.如何访问外部类的普通成员变量：
    static class InnerClass{
        public int data4=4;
        private int data5=5;
        public static final int data6=6;

        public InnerClass(){

        }

        //public OuterClass2 out=new OuterClass2();
        public OuterClass2 out;
        public InnerClass(OuterClass2 out){
            this.out=out;
        }


        public void test() {
            System.out.println(out.data1);
            System.out.println(out.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("InnerClass::test()");
        }
    }
}


class Test{

    public Test(){
        System.out.println("test:aaa");
    }

    public void test(){
        System.out.println("test() lea");
    }
}


public class TestDemo2 extends Test {

    public static void main(String[] args) {
        new Test(){
            @Override
            public void test() {
                System.out.println("我是重写的test方法");
            }
        }.test();
    }

    public static void main2(String[] args) {
        OuterClass2.InnerClass o=new OuterClass2.InnerClass();
    }

    public static void main1(String[] args) {
        OuterClass2 outerClass2=new OuterClass2();

        OuterClass2.InnerClass innerClass=new OuterClass2.InnerClass(outerClass2);
        innerClass.test();
    }
}
